package com.deyuanyun.pic.pipe.controller.vo;

import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.common.util.format.DateFormat;
import com.deyuanyun.pic.common.util.format.NumberFormat;
import com.deyuanyun.pic.pipe.domain.Closure;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

import java.util.ArrayList;
import java.util.List;

/**
 * 封堵物信息表
 */
public class ClosureVO extends BaseVO<Closure> {

    // 管道名称
    private String pipeLineName;
    // 封堵物编号
    private String customNumber;
    // 封堵物类型
    private String closureType;
    // 封堵物材料
    private String closureMaterial;
    // 绝对距离(m)
    private String mileage;
    // 相对最近参考点
    private String reference;
    // 相对最近参考点距离(m)
    private String referenceDistance;
    // 位置描述
    private String locationDescription;
    // 封堵物防腐材料
    private String antisepticMaterial;
    // 压力等级（MPa）
    private String pressureRating;
    // 投用日期
    private String inserviceDate;
    // 施工单位
    private String assemblyCompany;
    // 监理单位
    private String inspectingCompany;
    // 检测单位
    private String testingCompany;
    // 链接计算结果表
    private String gisId;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getCustomNumber() {
        return customNumber;
    }

    public void setCustomNumber(String customNumber) {
        this.customNumber = customNumber;
    }

    public String getClosureType() {
        return closureType;
    }

    public void setClosureType(String closureType) {
        this.closureType = closureType;
    }

    public String getClosureMaterial() {
        return closureMaterial;
    }

    public void setClosureMaterial(String closureMaterial) {
        this.closureMaterial = closureMaterial;
    }

    public String getMileage() {
        return mileage;
    }

    public void setMileage(String mileage) {
        this.mileage = mileage;
    }

    public String getReference() {
        return reference;
    }

    public void setReference(String reference) {
        this.reference = reference;
    }

    public String getReferenceDistance() {
        return referenceDistance;
    }

    public void setReferenceDistance(String referenceDistance) {
        this.referenceDistance = referenceDistance;
    }

    public String getLocationDescription() {
        return locationDescription;
    }

    public void setLocationDescription(String locationDescription) {
        this.locationDescription = locationDescription;
    }

    public String getAntisepticMaterial() {
        return antisepticMaterial;
    }

    public void setAntisepticMaterial(String antisepticMaterial) {
        this.antisepticMaterial = antisepticMaterial;
    }

    public String getPressureRating() {
        return pressureRating;
    }

    public void setPressureRating(String pressureRating) {
        this.pressureRating = pressureRating;
    }

    public String getInserviceDate() {
        return inserviceDate;
    }

    public void setInserviceDate(String inserviceDate) {
        this.inserviceDate = inserviceDate;
    }

    public String getAssemblyCompany() {
        return assemblyCompany;
    }

    public void setAssemblyCompany(String assemblyCompany) {
        this.assemblyCompany = assemblyCompany;
    }

    public String getInspectingCompany() {
        return inspectingCompany;
    }

    public void setInspectingCompany(String inspectingCompany) {
        this.inspectingCompany = inspectingCompany;
    }

    public String getTestingCompany() {
        return testingCompany;
    }

    public void setTestingCompany(String testingCompany) {
        this.testingCompany = testingCompany;
    }

    public String getGisId() {
        return gisId;
    }

    public void setGisId(String gisId) {
        this.gisId = gisId;
    }

    public void fromDomain(Closure domain) {

        if (ObjectUtil.isEmptyAll(domain)) {
            return;
        }
        // 管道名称
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 封堵物编号
        this.customNumber = domain.getCustomNumber();
        // 封堵物类型
        this.closureType = CodeUtil.getName(domain.getClosureType());
        // 封堵物材料
        this.closureMaterial = CodeUtil.getName(domain.getClosureMaterial());
        // 绝对距离(m)
        this.mileage = NumberFormat.format(domain.getMileage(), NumberFormat.FMT_PLACES3);
        // 相对最近参考点
        this.reference = domain.getReference();
        // 相对最近参考点距离(m)
        this.referenceDistance = NumberFormat.format(domain.getReferenceDistance(), NumberFormat.FMT_PLACES3);
        // 位置描述
        this.locationDescription = domain.getLocationDescription();
        // 封堵物防腐材料
        this.antisepticMaterial = CodeUtil.getName(domain.getAntisepticMaterial());
        // 压力等级（MPa）
        this.pressureRating = NumberFormat.format(domain.getPressureRating());
        // 投用日期
        this.inserviceDate = DateFormat.format(domain.getInserviceDate());
        // 施工单位
        this.assemblyCompany = domain.getAssemblyCompany();
        // 监理单位
        this.inspectingCompany = domain.getInspectingCompany();
        // 检测单位
        this.testingCompany = domain.getTestingCompany();
        // gis地址
        this.gisId = domain.getGisId();

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordtime(), domain.getCreateRemark());
    }

    public Page<ClosureVO> fromDomainList(Page<Closure> domainList) {
        Page<ClosureVO> list = new Page<ClosureVO>();
        for (Closure closure : domainList) {
            ClosureVO closureVO = new ClosureVO();
            closureVO.fromDomain(closure);
            list.add(closureVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }
}